/**
 * 
 */
package com.vincent.dao;

import org.springframework.stereotype.Component;

import com.vincent.dao.basic.BasicDao;
import com.vincent.pojo.User;

/**
 * 作者： Vincent
 * 创建日期： 2014年4月20日 上午10:23:26
 * 项目名字： MyForum
 */
@Component("userDAO")
public class UserDAO  extends BasicDao<User>{
	
	public User getUserByAccount(String account){
		
		String hqlString = "FROM User u WHERE u.userName = ?";
		
		Object []parameters = {account};
		
		return (User) this.executeQueryUniqueResult(hqlString, parameters);
	}
	
	public User getUserByEmail(String email){
		
		String hqlString = "FROM User u WHERE u.email = ?";
		
		Object []parameters = {email};
		
		return (User) this.executeQueryUniqueResult(hqlString, parameters);
	}
	
	public void saveUser(User u){
		
		this.savObject(u);
	}
	
	public User getUserById(int id){
		
		return this.getObjectById(id);
	}
}
